home *** CD-ROM | disk | FTP | other *** search
- library AddIn;
- uses
- ShareMem, ExptIntf, ToolIntf, Menus, Forms, Dialogs, Classes;
-
- { EXPERT TYPE DEFINITION }
-
- Type
- TBAddInExpert = class(TIExpert)
- public
- constructor Create; virtual;
- destructor Destroy; override;
-
- function GetStyle: TExpertStyle; override;
- function GetIDString: String; override;
- function GetName: String; override;
- function GetAuthor: String; override;
-
- protected
- procedure OnClick(Sender: TIMenuItemIntf); virtual;
-
- private
- MenuItem: TIMenuItemIntf;
- end {TBAddInExpert};
-
- { EXPERT SUPPORT FUNCTION }
-
- procedure HandleException;
- begin
- if Assigned(ToolServices) then
- ToolServices.RaiseException(ReleaseException)
- { Aplication.Handle := ToolServices.GetParentHandle; }
- end {HandleException};
-
- { EXPERT IMPLEMENTATION }
-
- constructor TBAddInExpert.Create;
- var Main: TIMainMenuIntf;
- ToolsTools: TIMenuItemIntf;
- Tools: TIMenuItemIntf;
- begin
- inherited Create;
- MenuItem := nil;
- if ToolServices <> nil then
- try
- Main := ToolServices.GetMainMenu;
- if Main <> nil then { we've got the main menu }
- try
- ToolsTools := Main.FindMenuItem('ViewPrjMgrItem'{ToolsToolsItem'});
- if ToolsTools <> nil then { we've got the " Tools | Tools" item }
- try
- Tools := ToolsTools.GetParent;
- if Tools <> nil then { we've got the Tools menu }
- try
- MenuItem := Tools.InsertItem(ToolsTools.GetIndex+1,
- '&Dr.Bob''s Expert',
- 'DrBob','',
- ShortCut(Ord('D'),[ssCtrl]),0,0,
- [mfEnabled, mfVisible], OnClick)
- finally
- Tools.DestroyMenuItem
- end
- finally
- ToolsTools.DestroyMenuItem
- end
- finally
- Main.Free
- end
- except
- HandleException
- end
- end {Create};
-
- destructor TBAddInExpert.Destroy;
- begin
- try
- if MenuItem <> nil then MenuItem.DestroyMenuItem;
- inherited Destroy
- except
- HandleException
- end
- end {Destroy};
-
- function TBAddInExpert.GetStyle: TExpertStyle;
- begin
- try
- Result := esAddIn
- except
- HandleException
- end
- end {GetStyle};
-
- function TBAddInExpert.GetIDString: String;
- begin
- try
- Result := 'DrBob.AddIn.Expert'
- except
- HandleException
- end
- end {GetIDString};
-
- function TBAddInExpert.GetName: String;
- begin
- try
- Result := 'DrBob.AddIn.Expert'
- except
- HandleException
- end
- end {GetName};
-
- function TBAddInExpert.GetAuthor: String;
- begin
- try
- Result := 'Bob.Swart'
- except
- HandleException
- end
- end {GetAuthor};
-
-
- procedure TBAddInExpert.OnClick(Sender: TIMenuItemIntf);
- begin
- try
- ShowMessage('Dr.Bob Says: Hello, World!'#10#10+
- 'Thank you for reading my'#10+
- 'Under Construction column'#10+
- 'in The Delphi Magazine!')
- except
- HandleException
- end
- end {OnClick};
-
- { DLL EXPERT INTERFACE }
-
- procedure DoneExpert;
- begin
- { ShowMessage(ParamStr(0)+' unloaded!') }
- end {DoneExpert};
-
- function InitExpert(ToolServices: TIToolServices;
- RegisterProc: TExpertRegisterProc;
- var Terminate: TExpertTerminateProc): Boolean; stdcall;
- begin
- try
- Result := True;
- ExptIntf.ToolServices := ToolServices; { Save! }
- if ToolServices <> nil then
- Application.Handle := ToolServices.GetParentHandle;
- Terminate := DoneExpert;
- Result := RegisterProc(TBAddInExpert.Create);
- except
- HandleException
- end
- end {InitExpert};
-
- exports
- InitExpert name ExpertEntryPoint;
-
- begin
- { ShowMessage(ParamStr(0)+' loaded!') }
- end.
-